﻿namespace OverStore.Exceptions
{
    using System;
    using System.Globalization;

    /// <summary>
    /// The exception that is thrown when trying to load instance
    /// or execute object reader with parameters of unsupported type.
    /// </summary>
    public sealed class ParameterTypeNotSupportedException : PersistenceOperationIsNotSupportedException
    {
        /// <summary>
        /// Initializes a new instance of the <see cref="ParameterTypeNotSupportedException"/> class.
        /// </summary>
        /// <param name="objectType">OverrideDbType of the object.</param>
        /// <param name="unsupportedType">OverrideDbType of the parameter that is unsupported.</param>
        public ParameterTypeNotSupportedException(Type objectType, Type unsupportedType)
            : base(String.Format(CultureInfo.InvariantCulture, "Reading object of type {0} with parameter of {1} type not supported", objectType, unsupportedType))
        {
            if (unsupportedType == null)
                throw new ArgumentNullException("unsupportedType");
            ParameterType = unsupportedType;

            if (objectType == null)
                throw new ArgumentNullException("objectType");
            ObjectType = objectType;
        }

        /// <summary>
        /// Get parameter type which is not supported.
        /// </summary>
        public Type ParameterType { get; private set; }

        /// <summary>
        /// Get object type trys to read with unsupported parameters.
        /// </summary>
        public Type ObjectType { get; private set; }
    }
}